package com.appleyk.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 总人数
 */
@Getter
public enum GenderEnum {

    FEMALE(1,"女"),
    MALE(0,"男"),
    ;

    private final Integer code;
    private final String name;

    GenderEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code 获取 中文性别
     * @param code code
     * @return return
     */
    public static String getGenderName(Integer code){
        if (code != null) {
            for (GenderEnum value : GenderEnum.values()) {
                if(Objects.equals(value.code, code)){
                    return value.name;
                }
            }
        }
        return null;
    }
}
